package com.sczmgk.hotline.entity;


import com.sczmgk.hotline.annotation.Column;
import com.sczmgk.hotline.annotation.CompareName;
import com.sczmgk.hotline.annotation.ID;
import com.sczmgk.hotline.annotation.TableName;
import com.sczmgk.hotline.annotation.Where;
import com.sczmgk.hotline.db.base.DBHelper;

@CompareName("msgtime")
@TableName(DBHelper.TABLE_CHAT_MSG)
public class ChatMsgBean implements Comparable<ChatMsgBean> {


    /**
     * 需要上传
     */
    public static final int NEED_UPLOAD = 1;
    /**
     * 不需要上传
     */
    public static final int DO_NOT_NPLOAD = 0;


    ////////////////////////////////环信消息附加属性key//////////////////////////
    /**
     * 发送目标key（1.机器人 android  2. 环信 online)
     */
    public static final String ATTR_KEY_SEND_TO = "send_to";
    /**
     * 接收对象key（1.机器人 android  2. 环信 online)
     */
    public static final String ATTR_KEY_RECEIVE = "service";

    /**
     * 消息id
     */
    public static final String ATTR_KEY_CHATID = "chatid";
    /**
     * 提示框展示
     */
    public static final String ATTR_KEY_HINT = "hint";
    /**
     * 提示框展示类型
     */
    public static final String ATTR_KEY_HINT_TYPE = "hint_type";

    ////////////////////////////////环信消息附加属性 value //////////////////////////
    /**
     * 来自小i机器人
     */
    public static final int ATTR_VALUE_ANDROID = 1;
    /**
     * 来自人工在线（环信）
     */
    public static final int ATTR_VALUE_ONLINE = 0;
    /**
     * 显示消息下面的提示
     */
    public static final int ATTR_VALUE_HINT_SHOW = 1;
    /**
     * 不显示消息下面的提示
     */
    public static final int ATTR_VALUE_HINT_HIDE = 0;
    /**
     * 提示在线服务
     */
    public static final int ATTR_VALUE_HINT_TYPE_ONLINE = 0;
    /**
     * 提示机器人服务
     */
    public static final int ATTR_VALUE_HINT_TYPE_ANDROID = 1;
    ////////////////////////////////////////////////////////////////////////

    public static final int MSG_STATUS_SENDING = 1;
    public static final int MSG_STATUS_SEND_SUCCESS = 2;
    public static final int MSG_STATUS_SEND_FAIL = 3;

    public static final int MSG_TYPE_TEXT = 1;
    public static final int MSG_TYPE_PIC = 2;
    public static final int MSG_TYPE_AUDIO = 3;
    public static final int MSG_TYPE_VIDEO = 4;

    public static final int SELF = 0;
    public static final int FROM = 1;

    public String getHeadUrl() {
        return headUrl;
    }

    public void setHeadUrl(String headUrl) {
        this.headUrl = headUrl;
    }

    public int getHintType() {
        return hintType;
    }

    public void setHintType(int hintType) {
        this.hintType = hintType;
    }

    public int getShowHint() {
        return showHint;
    }

    public void setShowHint(int showHint) {
        this.showHint = showHint;
    }


    /**
     * 是否需要上传到服务器
     */
    @Column(DBHelper.NEED_UPLOAD)
    private int needUpload;

    public int getNeedUpload() {
        return needUpload;
    }

    public void setNeedUpload(int needUpload) {
        this.needUpload = needUpload;
    }

    /**
     * 消息下方提示类型
     */
    private int hintType;

    private String headUrl;
    /**
     * 是否显示下方的提示
     */

    private int showHint;
    /**
     * 文件名
     */
    @Column(DBHelper.FILENAME)
    private String filename = "";
    /**
     * 客服名字
     */
    @Column(DBHelper.MSGFROM)
    private String msgfrom = "";
    /**
     * 群名
     */
    @Column(DBHelper.GROUPNAME)
    private String groupname = "";
    /**
     * 是否已读
     */
    @Column(DBHelper.ISACKED)
    private int isacked;
    /**
     * 是否送达
     */
    @Column(DBHelper.ISDELIVERED)
    private int isdelivered;
    /**
     * 是事接收
     */
    @Column(DBHelper.ISLISTENED)
    private int islistened;
    /**
     * 纬度
     */
    @Column(DBHelper.LATITUDE)
    private String latitude = "";
    /**
     * 经度
     */
    @Column(DBHelper.LONGITUDE)
    private String longitude = "";
    /**
     * 消息源   0 发送  1 接收
     */
    @Column(DBHelper.MSGDIR)
    private int msgdir;
    /**
     * 环信消息id
     */
    @Column(DBHelper.MSGID)
    private String msgid = "";
    /**
     * 消息生成时间
     */
    @Column(DBHelper.MSGTIME)
    private long msgtime;
    /**
     * 消息类型
     */
    @Column(DBHelper.MSGTYPE)
    private int msgtype;
    /**
     * 消息状态
     */
    @Column(DBHelper.STATUS)
    private int status;
    /**
     * 文本消息的内容
     */
    @Column(DBHelper.TEXTMSG)
    private String textmsg = "";
    /**
     * 用户的环信帐号
     */
    @Column(DBHelper.MSGTO)
    private String msgto = "";
    /**
     * 消息类型名字(此字段用于存手机imei)
     */
    @Column(DBHelper.TYPENAME)
    private String typename = "";
    /**
     * 文件URL
     */
    @Column(DBHelper.URL)
    private String url = "";
    /**
     * 用户id
     */
    @Column(DBHelper.USERID)
    private int userid;
    /**
     * 图片宽度
     */
    @Column(DBHelper.ISONLINE)
    private int isonline;

    public int getIsonline() {
        return isonline;
    }

    public void setIsonline(int isonline) {
        this.isonline = isonline;
    }

    /**
     * 消息id(我们管理)
     */
    @Where(isQuery = true)
    @Column(DBHelper.CHATID)
    private String chatid;
    /**
     * 表id
     */
    @Column(DBHelper.TABLE_ID)
    @ID(autoIncrement = true)
    private int id;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getChatid() {
        return chatid;
    }

    public void setChatid(String chatid) {
        this.chatid = chatid;
    }

    @Override
    public int compareTo(ChatMsgBean o) {
        // TODO Auto-generated method stub
        return 0;
    }

    public String getFilename() {
        return filename;
    }

    public void setFilename(String filename) {
        this.filename = filename;
    }

    public String getMsgfrom() {
        return msgfrom;
    }

    public void setMsgfrom(String msgfrom) {
        this.msgfrom = msgfrom;
    }

    public String getGroupname() {
        return groupname;
    }

    public void setGroupname(String groupname) {
        this.groupname = groupname;
    }

    public int getIsacked() {
        return isacked;
    }

    public void setIsacked(int isacked) {
        this.isacked = isacked;
    }

    public int getIsdelivered() {
        return isdelivered;
    }

    public void setIsdelivered(int isdelivered) {
        this.isdelivered = isdelivered;
    }

    public int getIslistened() {
        return islistened;
    }

    public void setIslistened(int islistened) {
        this.islistened = islistened;
    }

    public String getLatitude() {
        return latitude;
    }

    public void setLatitude(String latitude) {
        this.latitude = latitude;
    }

    public String getLongitude() {
        return longitude;
    }

    public void setLongitude(String longitude) {
        this.longitude = longitude;
    }

    public int getMsgdir() {
        return msgdir;
    }

    public void setMsgdir(int msgdir) {
        this.msgdir = msgdir;
    }

    public String getMsgid() {
        return msgid;
    }

    public void setMsgid(String msgid) {
        this.msgid = msgid;
    }

    public long getMsgtime() {
        return msgtime;
    }

    public void setMsgtime(long msgtime) {
        this.msgtime = msgtime;
    }

    public int getMsgtype() {
        return msgtype;
    }

    public void setMsgtype(int msgtype) {
        this.msgtype = msgtype;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getTextmsg() {
        return textmsg;
    }

    public void setTextmsg(String textmsg) {
        this.textmsg = textmsg;
    }

    public String getMsgto() {
        return msgto;
    }

    public void setMsgto(String msgto) {
        this.msgto = msgto;
    }

    public String getTypename() {
        return typename;
    }

    public void setTypename(String typename) {
        this.typename = typename;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public int getUserid() {
        return userid;
    }

    public void setUserid(int userid) {
        this.userid = userid;
    }

    /**
     * 生成文本消息
     *
     * @param isonline    //暂时用于区分机器人与人工客服
     * @param userid
     * @param typename
     * @param msgto
     * @param textmsg
     * @param status
     * @param msgtype
     * @param msgtime
     * @param msgid
     * @param msgdir
     * @param msgfrom
     * @param isacked
     * @param isdelivered
     * @param islistened
     * @return
     */
    public static ChatMsgBean getTextMsg(int needUpload, int isonline, int userid, String typename, String msgto, String textmsg, int status, int msgtype, long msgtime, String msgid, int msgdir, String msgfrom, int isacked, int isdelivered, int islistened, String chatId) {
        return new ChatMsgBean(needUpload, isonline, userid, "", typename, msgto, textmsg, status, msgtype, msgtime, msgid, msgdir, "", msgfrom, "", 0, 0, 0, "", "", chatId);
    }


    public ChatMsgBean(int needUpload, int isonline, int userid, String url, String typename, String msgto, String textmsg, int status, int msgtype, long msgtime, String msgid, int msgdir, String filename, String msgfrom, String groupname, int isacked, int isdelivered, int islistened, String latitude, String longitude, String chatId) {
        this.isonline = isonline;
        this.needUpload = needUpload;
        this.userid = userid;
        this.url = url;
        this.typename = typename;
        this.msgto = msgto;
        this.textmsg = textmsg;
        this.status = status;
        this.msgtype = msgtype;
        this.msgtime = msgtime;
        this.msgid = msgid;
        this.msgdir = msgdir;
        this.filename = filename;
        this.msgfrom = msgfrom;
        this.groupname = groupname;
        this.isacked = isacked;
        this.isdelivered = isdelivered;
        this.islistened = islistened;
        this.latitude = latitude;
        this.longitude = longitude;
        this.chatid = chatId;
    }

    /**
     * 生成自已管理的msgid
     *
     * @return
     */
    private String crateMyMsgId() {
        long timeMillis = System.currentTimeMillis();
        return String.valueOf(timeMillis) + "_" + userid;
    }

    public ChatMsgBean() {

    }

//	/**
//	 * 生成文本消息
//
//	 */
//	public static ChatMsgBean getTextMsg(){
//		return new ChatMsgBean(0,0,1,"","text","msgto","我是消息内容",1,1,2222,"35746541",1,0,"","msgfrom","",0,0,0,"","");
//	}
}
